using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using DataObject.Database;
using DataObject.Model;

	public partial class ProviderMapper
	{
		#region ToSingle

		public static ProviderDTO ToSingle(ProviderEntity entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ProviderDTO
			{
				Active = entity.Active,
				AddressLine1 = entity.AddressLine1,
				AddressLine2 = entity.AddressLine2,
				City = entity.City,
				CountryID = entity.CountryID,
				Description = entity.Description,
				Email = entity.Email,
				FaxNumber = entity.FaxNumber,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				PostalCode = entity.PostalCode,
				ProviderID = entity.ProviderID,
				ProviderName = entity.ProviderName,
				ProviderNumber = entity.ProviderNumber,
				Phone = entity.Phone,
				Website = entity.Website,
			};
		}

		#endregion

		#region ToEntity

		public static ProviderEntity ToEntity(ProviderEntity entity, ProviderDTO businessobject)
		{
			if (businessobject == null)
			{
				return null;
			}
			entity.Active = businessobject.Active;
			entity.AddressLine1 = businessobject.AddressLine1;
			entity.AddressLine2 = businessobject.AddressLine2;
			entity.City = businessobject.City;
			entity.CountryID = businessobject.CountryID;
			entity.Description = businessobject.Description;
			entity.Email = businessobject.Email;
			entity.FaxNumber = businessobject.FaxNumber;
			entity.ModifiedBy = businessobject.ModifiedBy;
			entity.ModifiedDate = businessobject.ModifiedDate;
			entity.PostalCode = businessobject.PostalCode;
			entity.ProviderID = businessobject.ProviderID;
			entity.ProviderName = businessobject.ProviderName;
			entity.ProviderNumber = businessobject.ProviderNumber;
			entity.Phone = businessobject.Phone;
			entity.Website = businessobject.Website;
			return entity;
		}

		#endregion

		#region ToBusinessObject

		public static ProviderDTO ToBusinessObject(ProviderEntity entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ProviderDTO
			{
				Active = entity.Active,
				AddressLine1 = entity.AddressLine1,
				AddressLine2 = entity.AddressLine2,
				City = entity.City,
				CountryID = entity.CountryID,
				Description = entity.Description,
				Email = entity.Email,
				FaxNumber = entity.FaxNumber,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				PostalCode = entity.PostalCode,
				ProviderID = entity.ProviderID,
				ProviderName = entity.ProviderName,
				ProviderNumber = entity.ProviderNumber,
				Phone = entity.Phone,
				Website = entity.Website,
			};
		}

		#endregion

		#region ToBusinessObjectHasChildren

		public static ProviderDTO ToBusinessObjectHasChildren(ProviderEntity entity, params Type[] types)
		{
			if (entity == null)
			{
				return null;
			}
			ProviderDTO businessobject = new ProviderDTO
			{
				Active = entity.Active,
				AddressLine1 = entity.AddressLine1,
				AddressLine2 = entity.AddressLine2,
				City = entity.City,
				CountryID = entity.CountryID,
				Description = entity.Description,
				Email = entity.Email,
				FaxNumber = entity.FaxNumber,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				PostalCode = entity.PostalCode,
				ProviderID = entity.ProviderID,
				ProviderName = entity.ProviderName,
				ProviderNumber = entity.ProviderNumber,
				Phone = entity.Phone,
				Website = entity.Website,
			};
			if (types.Contains<Type>(typeof(ProviderContact)) || types.Length == 0)
			{
				businessobject.ProviderContactCollection = new List<ProviderContactDTO>();
				foreach(var item in entity.ProviderContacts)
				{
                    businessobject.ProviderContactCollection.Add(ProviderContactMapper.ToBusinessObject(item));
				}
			}
			if (types.Contains<Type>(typeof(ReservationService)) || types.Length == 0)
			{
				businessobject.ReservationServiceCollection = new List<ReservationServiceDTO>();
				foreach(var item in entity.ReservationServices)
				{
                    businessobject.ReservationServiceCollection.Add(ReservationServiceMapper.ToBusinessObject(item));
				}
			}
			if (types.Contains<Type>(typeof(RouteService)) || types.Length == 0)
			{
				businessobject.RouteServiceCollection = new List<RouteServiceDTO>();
				foreach(var item in entity.RouteServices)
				{
					businessobject.RouteServiceCollection.Add(RouteServiceMapper.ToBusinessObject(item));
				}
			}
			if (types.Contains<Type>(typeof(ServiceProvider)) || types.Length == 0)
			{
				businessobject.ServiceProviderCollection = new List<ServiceProviderDTO>();
				foreach(var item in entity.ServiceProviders)
				{
					businessobject.ServiceProviderCollection.Add(ServiceProviderMapper.ToBusinessObject(item));
				}
			}
			return businessobject;
		}

		#endregion

	}
